import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;



public class SeleniumDemo {
    public WebDriver driver;
    @Test
    public void execute() throws InterruptedException {
        /**
         * 前置操作加载Chrome驱动
         */
        System.setProperty("webdriver.chrome.driver", this.getClass().getClassLoader().getResource("chromedriver/chromedriver.exe").getPath());
        driver = new ChromeDriver();
        driver.get("https://www.lanqiao.cn/");
        /* 窗口最大化 */
        driver.manage().window().maximize();
        WebElement element = driver.findElement(By.xpath("//*[@id=\"__BVID__21\"]"));
        //findElement,findElements
        element.sendKeys("selenium");
        WebElement element1 = driver.findElement(By.cssSelector("#__layout > div > div.base-header > div.header-primary > div.header-middle.h-full.flex.items-center > form > button > svg"));
        element1.click();
        Thread.sleep(1000);
        driver.quit();
    }
    //云课一个登录
    @Test
    public void runYunKe() throws InterruptedException {
        System.setProperty("webdriver.chrome.driver", this.getClass().getClassLoader().getResource("chromedriver/chromedriver.exe").getPath());
        driver = new ChromeDriver();
        driver.get("https://www.lanqiao.cn/");
        /* 窗口最大化 */
        driver.manage().window().maximize();
        //点击【登录】按钮=css:.sign-btn.signin
        WebElement login = driver.findElement(By.cssSelector(".sign-btn.signin"));
        Thread.sleep(1000);
        login.click();
        driver.findElement(By.xpath("//*[@id=\"__layout\"]/div/div/div/div/div/div/div/div[3]/span")).click();
        driver.findElement(By.xpath("//*[@id=\"__layout\"]/div/div/div/div/div/div/div[1]/div[3]/div[1]/div[2]/div/form/div[1]/div/div/span/input"))
                .sendKeys("123456");
        driver.findElement(By.xpath("//*[@id=\"__layout\"]/div/div/div/div/div/div/div[1]/div[3]/div[1]/div[2]/div/form/div[2]/div/div/span/span/input"))
                .sendKeys("123456");
        driver.findElement(By.xpath("//*[@id=\"__layout\"]/div/div/div/div/div/div/div[1]/div[3]/div[1]/div[2]/div/div[2]/button"))
                .click();
        Thread.sleep(2000);
//        结束进程
        driver.quit();

    }
}
